﻿@{
    var SearchParma = ViewData["SearchParma"] as HanGu.Entity.UniversallySearchParam ?? new HanGu.Entity.UniversallySearchParam();    
}
<div class="pagebar">
    <ul>
        <li>总页数/当前页</li>
        <li>@SearchParma.Pagination.PageTotal/@SearchParma.Pagination.CurrentIndex</li>
        <li><a href="#" onclick="firstPage()">首页</a></li>
        <li>
            @if (SearchParma.Pagination.CurrentIndex > 1)
            {
                <a href="#" onclick="PrePage()">上一页</a>}
            else
            {
                <span>上一页</span>
            }
        </li>
        <li>
            @if (SearchParma.Pagination.CurrentIndex < SearchParma.Pagination.PageTotal)
            {
                <a href="#" onclick="NextPage()">下一页</a>}
            else
            {
                <span>下一页</span>
            }
        </li>
        <li><a href="#" onclick="LastPage()">尾页</a></li>
        <li>跳转到第
            <select onchange="SelectPage(this)">
                @for (int i = 1; i <= SearchParma.Pagination.PageTotal; i++)
                {
                    if(i==SearchParma.Pagination.CurrentIndex){
                    <option value="@i" selected="selected">@i</option>
                    }
                    else
                    {
                    <option value="@i">@i</option>
                    }
                }
            </select>
            页 </li>
    </ul>
</div>
<script>
var pageform=$('#@ViewData["pageform"]');
var currentPage = $("input[name='pageNum']", pageform);
var currentPageIndex=parseInt(currentPage.val());
function firstPage()
{
currentPage.val(1);
pageform.submit();
}
function LastPage()
{
currentPage.val('@SearchParma.Pagination.PageTotal');
pageform.submit();
}
function NextPage()
{
currentPage.val(currentPageIndex+1);
pageform.submit();
}
function PrePage()
{
currentPage.val(currentPageIndex-1);
pageform.submit();
}
function SelectPage(obj)
{
currentPage.val($(obj).val());
pageform.submit();
}
</script>
